function toDate(datetimeStr) {
	var datetimePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
	var matchArray = datetimeStr.match(datetimePat);
	bulan = matchArray[1];
	tanggal = matchArray[3];
	tahun = matchArray[5];
	hour = 0;
	minute = 0;
	second = 0;
	datetimeform = new Date(tahun,bulan-1,tanggal,hour,minute,second);
	return datetimeform;
}
function IsValidDate(dateStr) {

	var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;

	var matchArray = dateStr.match(datePat);
	if (matchArray == null) {
		alert("Date is not in a valid format.");
		return false;
	}
	bulan = matchArray[1];
	tanggal = matchArray[3];
	tahun = matchArray[5];
	if (bulan < 0  || bulan > 12) {
		alert("Month must be between 1 and 12");
		return false;
	}
	if (bulan==2) {
		if ((tahun % 4)==0) {
			if (tanggal < 0 || tanggal>29) {
				alert ("Day must be between 1 and 29.");
				return false;
			}
		}
		else {
			if (tanggal < 0 || tanggal>28) {
				alert ("Day must be between 1 and 28.");
				return false;
			}
		}
	}
	else {
		if (bulan==1 || bulan==3 || bulan==5 || bulan==7 || bulan==8 || bulan==10 || bulan==12) {
			if (tanggal < 0 || tanggal > 31) {
				alert ("Day must be between 1 and 31.");
				return false;
			}
		}
		else {
			if (tanggal < 0 || tanggal > 30) {
				alert ("Day must be between 1 and 30.");
				return false;
			}
		}
	}
	if(tahun<1000){
		alert("Date is not in a valid format.");
		return false;
	}
	return true;
}
